{extend name="common/layout" /}
{block name="main"}
<div class="admin-main layui-anim layui-anim-upbit">

    <div class="demoTable padding30 padding-left30">
        <h3 class="page-box-title">{:lang('All Messages')}</h3>
        <div class="layui-inline">
            <input class="layui-input layui-search-input" name="key" id="key" placeholder="{:lang('Please enter the keyword')}">
        </div>
         <button class="layui-btn layui-search-btn" id="search" data-type="reload">{:lang('Search')}</button>
       
       
        
        <button class="layui-btn layui-btn-primary backgroundred _all borderrad5" data-href="{:U('delete')}" data-confirm="{:lang('Do you decide to delete the selected message?')}">{:lang('Delete')}</button>
        <button class="layui-btn _all layui-btn-primary borderrad5" data-href="{:U('reds')}" data-confirm="{:lang('Do you determine the message selected for the tag?')}">{:lang('Tag Read')}</button>
        <div style="clear: both;"></div>
    </div>
    <div class="" id="_listBox">
        <table class="layui-table" id="list" lay-filter="list"></table>
    </div>
</div>
{/block}
{block name="footer"}
<script type="text/html" id="title">
    <a href="#" data-href="{:url('view')}?message_id={{d.id}}" data-title="{:lang('Messages')}" class="_title _layer-dialog" data-skin="iframe-content-white2" data-aid="{$is_red}">{{d.title}} 
        {{d.is_red == 0 ? '<span class="layui-badge-dot"></span>' : ''}} 
    </a>
</script>
   <script type="text/javascript">
   	layui.use(['table','layer'], function() {
   		 var table = layui.table, $ = layui.jquery, layer = layui.layer;
   		 var tableIn = table.render({
            id: 'message',
            elem: '#list'
            ,url: '{:url("getLists",array('is_red'=>$is_red))}',
            method:'post',
            page:getPageThume()
            ,cols: [[
                {checkbox: true, fixed: true},
                {field:'title', title: "{:lang('Title')}", width:"45%",templet: '#title'}
                ,{field:'type', title: "{:lang('Type')}", width:"20%"}
                ,{field:'create_time', title: "{:lang('Create Time')}", width:"20%",sort:true}
            ]]
        });
        //搜索
        $('#search').on('click', function () {
            var key = $('#key').val();
            tableIn.reload({
                where: {key: key}
            });
        });
        $('._all').click(function(){
            var _this = $(this);
            layer.confirm(_this.data('confirm'), {icon: 3}, function(index) {
                layer.close(index);
                var checkStatus = table.checkStatus('message'); //test即为参数id设定的值
                var ids = [];
                $(checkStatus.data).each(function (i, o) {
                    ids.push(o.id);
                });
                var loading = layer.load(1, {shade: [0.1, '#fff']});
                $.post(_this.data('href'), {ids: ids}, function (data) {
                    layer.close(loading);
                    if (data.code === 1) {
                        layer.msg(data.msg, {time: 1000, icon: 1});
                        tableIn.reload();
                    } else {
                        layer.msg(data.msg, {time: 1000, icon: 2});
                    }
                });
            });
        })
         
    })
   </script>
{/block}